from math import inf
from collections import *
import math, os, sys, heapq, bisect, random
from functools import lru_cache
from itertools import *
def inp(): return sys.stdin.readline().rstrip("\r\n")
def out(var): sys.stdout.write(str(var)) def inpu(): return int(inp())
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def fsep(): return map(float, inp().split())
M,M1=1000000007,998244353
def main():
how_much_noob_I_am = 1
how_much_noob_I_am = inpu()
for i in range(how_much_noob_I_am):
s=inp()
ss=set()
d=defaultdict(int)
for i in s:
d[i]+=1
ans=""
for i in range(len(s)):
d[s[i]]-=1
if d[s[i]]==0:
break
print(s[i:])
if __name__ == '__main__':
main()
#include <bits/stdc++.h>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//#define int long long
//#define double long double
typedef long long ll;
typedef unsigned long long ull;
#define fir first
#define sec second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define sz(v) (int)(v).size()
//typedef tree<int, null_type, less_equal<>, rb_tree_tag,
// tree_order_statistics_node_update> indexed_multiset;
const int inf = 1000000000;
const ll INF = (ll)inf * (ll)inf;
const double EPS = 1e-9;
const double PI = 3.141592653;
mt19937_64 Rand(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count());
void solve()
{
string s; cin >> s;
vector <int> p(26, inf);
for (int i = 0; i < sz(s); ++i)
{
p[s[i]-'a'] = i;
}
int mn = sz(s)-1;
for (int i = 0; i < 26; ++i)
mn = min(mn, p[i]);
cout << s.substr(mn, sz(s) - mn) << '\n';
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int tt = 1; cin >> tt;
while (tt--){
solve();
}
}
Divisibility | A. Movement |
Numbers in a matrix | Sequences |
Split houses | Divisible |
Three primes | Coprimes |
Cost of balloons | One String No Trouble |
Help Jarvis! | Lift queries |
Goki and his breakup | Ali and Helping innocent people |
Book of Potion making | Duration |
Birthday Party | e-maze-in |
Bricks Game | Char Sum |
Two Strings | Anagrams |
Prime Number | Lexical Sorting Reloaded |
1514A - Perfectly Imperfect Array | 580A- Kefa and First Steps |
1472B- Fair Division | 996A - Hit the Lottery |
MSNSADM1 Football | MATCHES Playing with Matches |